import { userAccountLogin } from '@/api/user'

export default ({
  namespaced: true,
  state: {
    profile: {}
  },
  mutations: {
    setprofile (state, payload) {
      state.profile = payload
    },
    removeProfile (state) {
      state.profile = {}
    }
    /* 持久化存储测试 */
    /* setprofile (state) {
      state.profile.id = 10001
    } */
  },
  actions: {
    // 函数 调接口 传参数
    async fetchProfile (ctx, { account, password }) {
      const res = await userAccountLogin({ account, password })
      ctx.commit('setprofile', res.data.result)
    }
  }
})
